/********************************** (C) COPYRIGHT *******************************
* File Name          : main.c
* Author             : WCH
* Version            : V1.0.0
* Date               : 2021/06/06
* Description        : Main program body.
*********************************************************************************
* Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
* Attention: This software (modified or not) and binary are used for 
* microcontroller manufactured by Nanjing Qinheng Microelectronics.
*******************************************************************************/

/*
 *@Note
 USART Print debugging routine:
 USART1_Tx(PA9).
 This example demonstrates using USART1(PA9) as a print debug port output.

*/

#include "debug.h"
#include "spwm.h"
#include "get_data.h"

u16 ua[64]={1000,1084,1168,1250,1329,1405,1478,1545,1607,1663,1713,1755,1790,1817,1837,1847,1850,1844,
        1830,1807,1777,1739,1693,1641,1582,1518,1448,1375,1297,1216,1134,1050,965,881,798,717,639,
        564,494,429,369,316,269,229,198,174,158,151,152,161,179,204,238,279,328,383,444,510,582,657,736,818,901,985
};
u16 ub[64]={1736,1690,1638,1579,1514,1444,1370,1292,1212,1129,1045,960,876,793,712,634,
        560,490,425,366,313,266,227,196,173,157,150,152,162,180,206,240,282,331,386,
        447,514,586,662,741,822,906,990,1075,1158,1240,1320,1397,1469,1537,1600,1657,
        1707,1751,1787,1815,1835,1847,1850,1845,1832,1810,1781,1743
};
u16 uc[64]={264,225,194,171,157,150,152,163,181,208,243,285,334,389,451,518,590,
        666,745,827,911,995,1079,1163,1245,1325,1401,1474,1541,1604,1660,
        1710,1753,1788,1816,1836,1847,1850,1844,1831,1809,1779,1741,1696,
        1644,1586,1522,1453,1379,1302,1221,1139,1055,970,886,803,722,643,568,498,432,372,318,271
};

extern vu16 num;
/*********************************************************************
 * @fn      main
 *
 * @brief   Main program.
 *
 * @return  none
 */
int main(void)
{

	NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
	SystemCoreClockUpdate();
	Delay_Init();
	USART_Printf_Init(115200);	
	printf("SystemClk:%d\r\n",SystemCoreClock);
	printf( "ChipID:%08x\r\n", DBGMCU_GetCHIPID() );
	printf("This is printf example\r\n");

	spwm_init(2000-1,15-1);//3.2KHz
	timer_set(2000-1,960-1);//50Hz

	while(1)
    {
	    TIM_SetCompare1(TIM1,ua[num]);
        TIM_SetCompare2(TIM1,ub[num]);
        TIM_SetCompare3(TIM1,uc[num]);
	}
}



